home *** CD-ROM | disk | FTP | other *** search
/ Java for 3D & VRML Worlds / Java for 3d and VRML Worlds.iso / doc / homepage / tv.lzh / tv / scripts / r.tcl
Text File  |  1995-12-24  |  10KB  |  431 lines

  1.  
  2. vstkInit
  3.  
  4. proc Frame {fr channel val} {
  5.    global TvObj
  6.    set no [lindex [$channel configure -text] 4]
  7.    set obj $TvObj($no)
  8.  
  9.    vsGet3DMovieInfo $obj cur max loop
  10.    #vsGet3DMovieInfo $obj cur max 
  11.    #vsGet3DMovieInfo $obj cur 
  12.  
  13.    incr cur $val 
  14.    if {$cur < 0} { 
  15.        set cur [expr $max - 1]
  16.    }
  17.    if {$cur >= $max} {
  18.        set cur 0
  19. #vsMessageDlg "$cur"
  20.    } 
  21.    vsSet3DMovieFrame $obj   $cur
  22.    vsGet3DMovieInfo $obj cur mmax 
  23.    $fr configure -text $cur
  24.  
  25. #vsMessageDlg "$cur $max $loop"
  26. }
  27.  
  28. proc ChCtrl {obj ev data} { 
  29.     if {$data == "up"} {
  30.         set val 1
  31.     } else { 
  32.         set val -1
  33.     }
  34.     Channel  .frame8.lchannel $val
  35. }
  36. proc VolCtrl {obj ev data} { 
  37.     if {$data == "up"} { 
  38.         set val 10
  39.     } else {
  40.         set val -10
  41.     }
  42.  
  43.     Volume .frame10.lspeed  .frame8.lchannel $val 
  44. }   
  45.  
  46. proc Pause {obj} {
  47.     global TvObj
  48.    
  49.     set l [lindex [$obj configure -text] 4]
  50.     if {$l == "Pause"} {
  51.         set no [lindex [.frame8.lchannel configure -text] 4]
  52.         vsPause3DMovie $TvObj($no)
  53.         vsStopSoundByName channel$no
  54.         set l Play
  55.     } else { 
  56.         PlayChannel
  57.         set l Pause
  58.         .frame11.lspeed configure -text "***"
  59.     }
  60.     $obj configure -text $l
  61. }
  62.  
  63.  
  64. proc ObjVisible {obj flg} {
  65.     global vsCSWorld vsAbsolute vsObjAttrVisible
  66.     
  67.     vsSetObjAttribute $obj $vsObjAttrVisible $flg
  68. }
  69.  
  70. proc PowerPick {obj ev user} {
  71.     OnOff .frame0.button2 1
  72. }
  73. proc TvInit {obj ev no} {
  74.  
  75.     global TvObj vsFalse
  76.  
  77. vsGetObjByName $obj a
  78. #vsMessageDlg "$no"
  79.     set TvObj($no) $obj
  80.     if {! $no} { 
  81.         return 
  82.     }
  83.     ObjVisible $obj $vsFalse
  84. }
  85.  
  86. proc SuspendAll {} {
  87.     global TvObj vsTrue vsFalse
  88.     foreach d {1 2 3} {
  89.         ObjVisible $TvObj($d) $vsFalse
  90.         vsPause3DMovie $TvObj($d)
  91.         vsStopSoundByName channel$d
  92.     }
  93.     ObjVisible $TvObj(0) $vsTrue
  94. }
  95.  
  96.  
  97. proc ResetChanDisp {} {
  98.     global TvObj vsTrue vsFalse vsDiffuse vsTransparency
  99.     foreach d { 1 2 3 } { 
  100.         set pb [vsGetObjByName world.TVsep.TVIn.TV.Button.CH$d]
  101.         vsSetObjAllMaterial $pb $vsDiffuse 0.7 1.0 0.7
  102.         vsSetObjAllMaterial $pb $vsTransparency 1.0
  103.     }
  104. }
  105.  
  106. ##################################
  107. # Display (Channel Display) clean Timeouthandler Id
  108. ##################################
  109. set RmChThId 0
  110.  
  111. proc HideChanDisp {notuse ev user} {
  112.      global RmChThId 
  113.      ResetChanDisp
  114.      set RmThId 0
  115. }
  116.  
  117. proc ShowChanDisp {no} {
  118.     global vsDiffuse vsTransparency RmChThId
  119.     global vsTclScript vsSporadicTask
  120.  
  121.     set pb [vsGetObjByName world.TVsep.TVIn.TV.Button.CH$no]    
  122.     vsSetObjAllMaterial $pb $vsTransparency 0.0
  123.     # pb is only dummy.
  124.     if {$RmChThId} {
  125.         vsRemoveTimeOutHandler $pb $RmChThId
  126.     }
  127.     set RmThId [vsAddTimeOutHandler "$pb" 6200 \
  128.                      $vsTclScript "" HideChanDisp \
  129.                      "data" $vsSporadicTask]
  130. }
  131.  
  132. proc PlayChannel {} {
  133.  
  134.     global TvObj vsTrue vsFalse vsDiffuse vsTransparency
  135.  
  136.     set no [lindex [.frame8.lchannel configure -text] 4]
  137.     ObjVisible $TvObj($no) $vsTrue
  138.     ObjVisible $TvObj(0) $vsFalse
  139.     vsPlay3DMovie $TvObj($no)
  140.     vsPlayAmbientSoundByName channel$no $vsTrue
  141.  
  142.     ResetChanDisp
  143.     ShowChanDisp $no
  144.  
  145. }
  146.  
  147. proc ResetVolBar {} {
  148.     global vsTransparency vsDiffuse
  149.  
  150.     for {set i 1} { $i <= 10 } {incr i} { 
  151.         set pb [vsGetObjByName world.TVsep.TVIn.TV.Button.VOL$i]    
  152.         vsSetObjAllMaterial $pb $vsTransparency 1.0
  153.         vsSetObjAllMaterial $pb $vsDiffuse 0.3 0.3 0.3
  154.     }     
  155. }
  156.  
  157. ##################################
  158. # Display clean Timeouthandler Id
  159. ##################################
  160. set RmThId 0
  161.  
  162. proc HideVolBar {notuse ev user} {
  163.      global RmThId 
  164.      ResetVolBar
  165.      set RmThId 0
  166. }
  167.  
  168. proc ShowVolBar {vol} { 
  169.     global RmThId 
  170.  
  171.     global vsTransparency vsDiffuse vsTclScript vsSporadicTask
  172.  
  173.     for {set i 1} { $i <= 10 } {incr i} { 
  174.         set pb [vsGetObjByName world.TVsep.TVIn.TV.Button.VOL$i]    
  175.         vsSetObjAllMaterial $pb $vsTransparency 0.0
  176.         if { $i <= $vol } { 
  177.             vsSetObjAllMaterial $pb $vsDiffuse 0.7 1.0 0.7
  178.         }
  179.     }     
  180.     # pb is only dummy.
  181.     if {$RmThId} {
  182.         vsRemoveTimeOutHandler $pb $RmThId
  183.     }
  184.     set RmThId [vsAddTimeOutHandler "$pb" 2200 \
  185.                      $vsTclScript "" HideVolBar \
  186.                      "data" $vsSporadicTask]
  187. }
  188. proc Volume {obj channel flg} {
  189. #vsMessageDlg vol 
  190.     set vol [lindex [$obj configure -text] 4]
  191.     set vol [expr $vol + $flg]
  192.     if {$vol > 100} {
  193.         set vol 100
  194.     }
  195.     if {$vol < 0} {
  196.         set vol 0
  197.     }     
  198.  
  199.     set no [lindex [$channel configure -text] 4]
  200. #vsMessageDlg [expr 256 / 100 * $vol]
  201.  
  202.     vsSetSoundVolumeByName channel$no [expr 256 / 100 * $vol]
  203.  
  204.     ResetVolBar
  205.     ShowVolBar "[expr $vol / 10]"
  206.     $obj configure -text $vol
  207. }
  208.  
  209. proc Channel {obj flg} {
  210.     global TvObj vsObjAttrVisible vsTrue vsFalse
  211.  
  212.     set now [ lindex [$obj configure -text] 4 ]
  213.    
  214.     incr now $flg 
  215.     if {$now > 3} { 
  216.         set now 1
  217.     } 
  218.     if {$now < 1} { 
  219.         set now 3
  220.     }
  221.     $obj configure -text $now
  222.     set tvobj $TvObj($now)
  223.     if {[ lindex [ .frame0.button2 configure -text] 4 ] == "Off"} {
  224.        SuspendAll
  225.        PlayChannel
  226.     }
  227. }
  228. proc OnOff {obj sound} {
  229.     global TvObj  vsFalse vsTrue vsDiffuse
  230.  
  231.     #set pb [vsGetObjByName TV.Button.CH1]
  232.     set pb [vsGetObjByName world.TVsep.TVIn.TV.Button.Power]
  233.     #set pb [vsGetObjByName world.Power]
  234.     set now [ lindex [$obj configure -text] 4 ]
  235.     if {$now == "On"} {
  236.         set lab Off
  237.         # power ON.  TODO...
  238.         vsPlayAmbientSoundByName power $vsFalse
  239.         PlayChannel
  240.         .frame0.label1 configure -background green
  241.         vsSetObjAllMaterial $pb $vsDiffuse 0.0 1.0 0.0
  242.         wm deiconify .
  243.     } else {
  244.         set lab On
  245.         SuspendAll
  246.         .frame0.label1 configure -background gray
  247.         vsSetObjAllMaterial $pb $vsDiffuse 1.0 0.0 0.0
  248.         #wm withdraw . 
  249.     }
  250.     $obj configure -text $lab
  251. }
  252.  
  253. proc Control {mode} {
  254.     global TvObj
  255.     
  256.     set now [ lindex [.frame8.lchannel  configure -text] 4 ]
  257.     set speed [vsGet3DMovieSpeed $TvObj($now)]
  258.     switch $mode {
  259.     up   { set v 0.1}
  260.     down { set v -0.1}
  261.     }
  262.     set vv [expr $v + $speed]
  263.     .frame3.lspeed configure -text $vv
  264.     set now [lindex [.frame8.lchannel configure -text] 4]
  265.     vsSet3DMovieSpeed $TvObj($now) $vv 
  266.     #Pause .frame11.bpause
  267.     #Pause .frame11.bpause
  268. }
  269.  
  270.     
  271. # procedure to show window .
  272. proc ShowWindow. {args} {# xf ignore me 7
  273.  
  274.   # Window manager configurations
  275.   global tkVersion
  276.   wm positionfrom . user
  277.   wm sizefrom . ""
  278.   wm maxsize . 1280 1024
  279.   wm title . {Remote control}
  280.  
  281.  
  282.   # build widget .frame0
  283.   frame .frame0 \
  284.     -borderwidth {2} \
  285.     -relief {raised}
  286.  
  287.   # build widget .frame0.label1
  288.   label .frame0.label1 \
  289.     -relief {sunken} \
  290.     -background gray \
  291.     -text {Power}
  292.  
  293.   # build widget .frame0.button2
  294.   button .frame0.button2 \
  295.     -text {On} -command "OnOff .frame0.button2 1"
  296.  
  297.   # pack widget .frame0
  298.   pack append .frame0 \
  299.     .frame0.label1 {left frame center expand fillx} \
  300.     .frame0.button2 {top frame center}
  301.  
  302.   # build widget .frame3
  303.   frame .frame3 \
  304.     -borderwidth {2} 
  305.  
  306.   # build widget .frame3.lspeed
  307.   label .frame3.lsd \
  308.     -relief {sunken} \
  309.     -text {Speed} 
  310.  
  311.   label .frame3.lspeed \
  312.     -text {1.0} 
  313.  
  314.   # build widget .frame3.bfor
  315.   button .frame3.bfor \
  316.     -text {->} -command "Control up"
  317.  
  318.   # build widget .frame3.bback
  319.   button .frame3.bback \
  320.     -text {<-} -command "Control down"
  321.  
  322.   # pack widget .frame3
  323.   pack append .frame3 \
  324.     .frame3.lsd {left frame n expand fillx} \
  325.     .frame3.bback {left frame nw} \
  326.     .frame3.lspeed {left frame n expand fillx} \
  327.     .frame3.bfor {left frame nw}
  328.  
  329.   # build widget .frame8
  330.   frame .frame8 \
  331.     -borderwidth {2}
  332.  
  333.   label .frame8.lcl \
  334.     -relief {sunken} \
  335.     -text {Channel} 
  336.  
  337.   # build widget .frame8.bcback
  338.   button .frame8.bcback \
  339.     -text {<-} -command "Channel  .frame8.lchannel -1"
  340.  
  341.   # build widget .frame8.bcfor
  342.   button .frame8.bcfor \
  343.     -text {->} -command "Channel  .frame8.lchannel 1"
  344.  
  345.   # build widget .frame8.lchannel
  346.   label .frame8.lchannel \
  347.     -relief {groove} \
  348.     -text {1}
  349.  
  350.   # pack widget .frame8
  351.   pack append .frame8 \
  352.     .frame8.lcl {left frame nw expand fillx} \
  353.     .frame8.bcback {left frame nw} \
  354.     .frame8.lchannel {left frame nw expand fillx} \
  355.     .frame8.bcfor {left frame nw}
  356.  
  357.  
  358.  
  359. #################
  360.   # build widget .frame10
  361.   frame .frame10 \
  362.     -borderwidth {2} 
  363.  
  364.   # build widget .frame10.lspeed
  365.   button .frame10.lvol \
  366.     -relief {sunken} \
  367.     -text {Volume} 
  368.  
  369.  label .frame10.lspeed \
  370.     -text {100} 
  371.  
  372.   # build widget .frame10.bfor
  373.   button .frame10.bfor \
  374.     -text {->} -command "Volume .frame10.lspeed  .frame8.lchannel 10"
  375.  
  376.   # build widget .frame10.bback
  377.   button .frame10.bback \
  378.     -text {<-} -command "Volume .frame10.lspeed  .frame8.lchannel -10"
  379.  
  380.   # pack widget .frame10
  381.   pack append .frame10 \
  382.     .frame10.lvol {left frame n expand fillx} \
  383.     .frame10.bback {left frame nw} \
  384.     .frame10.lspeed {left frame n expand fillx} \
  385.     .frame10.bfor {left frame nw}
  386.  
  387.  
  388.   # build widget .frame11
  389.   frame .frame11 \
  390.     -borderwidth {2}
  391.  
  392.   # build widget .frame11.bpause
  393.   button .frame11.bpause \
  394.     -text {Pause} -command "Pause .frame11.bpause"
  395.  
  396.   # build widget .frame11.lspeed
  397.  
  398.   label .frame11.lspeed \
  399.     -text {***}
  400.  
  401.   # build widget .frame11.bfor
  402.   button .frame11.bfor \
  403.     -text {->} -command "Frame .frame11.lspeed  .frame8.lchannel 1"
  404.  
  405.   # build widget .frame11.bback
  406.   button .frame11.bback \
  407.     -text {<-} -command "Frame .frame11.lspeed  .frame8.lchannel -1"
  408.  
  409.   # pack widget .frame11
  410.   pack append .frame11 \
  411.     .frame11.bpause {left frame n expand fillx} \
  412.     .frame11.bback {left frame nw} \
  413.     .frame11.lspeed {left frame n expand fillx} \
  414.     .frame11.bfor {left frame nw}
  415.  
  416.  
  417. ##########
  418.   # pack widget .
  419.   pack append . \
  420.     .frame0 {top frame center expand fillx} \
  421.     .frame8 {top frame center expand fillx} \
  422.     .frame3 {bottom frame center expand fillx} \
  423.     .frame10 {bottom frame center expand fillx} \
  424.     .frame11 {bottom frame center expand fillx}
  425.  
  426. }
  427.  
  428. # display/remove toplevel windows.
  429. wm deiconify .
  430. ShowWindow.
  431.